#pragma GCC optimize(2)
#include <bits/stdc++.h>

using namespace std;
#define int long long
const int inf = 0x3f3f3f3f3f3f3f3f;

void solve()
{
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    int cnt1 = 0, cnt2 = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        cnt1 += a[i] == 1;
        cnt2 += a[i] == 2;
    }
    sort(a.begin(), a.end(), greater<int>());
    int ans = 0;
    for (int i = 0; i < n - 1; i++) ans += gcd(a[i], a[i + 1]);
    if (ans < k || k < n - 1) cout << -1 << endl;
    else if (ans == k) for (int i = 0; i < n; i++) cout << a[i] << ' ';
    else
    {
        ans -= k;
        vector<int> ret;
        for (int i = 0; i < ans; i++)
        {
            if (cnt1 && cnt2)
            {
                ret.push_back(2);
                ret.push_back(1);
                cnt1--;
                cnt2--;
            }
            else
            {
                cout << -1 << endl;
                return;
            }
        }
        if (cnt2) for (int i = 0; i < cnt2; i++) ret.push_back(2);
        if (cnt1) for (int i = 0; i < cnt1; i++) ret.push_back(1);
        for (int i = 0; i < n; i++) cout << ret[i] << ' ';
        cout << endl;
    }
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int _ = 1;
    //cin >> _;
    while (_--)
    {
        solve();
    }
    return 0;
}